package pattern.behavioral.Interpreter.simple;

/**
 * @author: chaoyang.ren  
 * @date:Jun 22, 2017  
 * @time:4:35:50 PM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class Test {
	public static void main(String[] args) {
		Context ctx = new Context();
        Variable x = new Variable("x");
        Variable y = new Variable("y");
        Constant c = new Constant(true);
        ctx.assign(x, false);
        ctx.assign(y, true);
        
        Expression exp = new Or(new And(c,x) , new And(y,new Not(x)));
        System.out.println("x=" + x.interpret(ctx));
        System.out.println("y=" + y.interpret(ctx));
        System.out.println(exp.toString() + "=" + exp.interpret(ctx));
	}
}

